home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
lineed.zip
/
LINEED.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-05
|
52KB
|
2,143 lines
/* LineEd (Line Editor) copyright (c) 1988/89/90/92 by M. Kimes
An XBBS Utility */
#include "lineed.h"
#ifdef __TURBOC__
#define _fastcall pascal
#endif
#define ORIGMSG "Original msg "
#define VERSION "1.06"
char * pascal stripcr(char *);
void pascal hitreturn(void);
void pascal cls (void);
char pascal inkey (void);
char pascal carrchk (void);
char pascal fossil (char function, char arg);
char pascal printm (char *text);
void cdecl deinitialize (void);
char * pascal genin (char length,char password,char caps,char hot,char type);
long pascal getxbbstime(void);
char pascal specialkey(char);
char pascal specialmod(void);
char * pascal rstrip(char *);
char * pascal lstrip(char *);
int cdecl break_handler(void);
void pascal chat(void);
void pascal rawdir (char *,char);
int pascal checkafile(char *);
char pascal readtext (char *);
int cdecl printfm(char *,...);
int pascal do_args (int argc, char *argv[]);
word pascal enter (word);
void pascal patchup (word,int);
void pascal delete (void);
struct line * pascal dls_store (struct line *);
struct line * pascal find (word);
void pascal search (void);
word pascal list (void);
word pascal save (word,word);
void pascal load (char);
int pascal menu_select (void);
void pascal wrap (char *,char *);
word pascal findlast (void);
void pascal printheader (void);
struct line * pascal newbuffer (void);
void pascal deleteline (word);
void pascal quoter (void);
void pascal edit (word);
void pascal view (char);
void pascal movelines (void);
void pascal status (char);
void pascal quit (char);
void pascal formpara (void);
int pascal printg(char *text);
/***********************************/
/* functions in ansi.c (low-level) */
/***********************************/
/* NOTE: all screen output except for status line should go (ultimately)
* through ansi().
*/
int _fastcall ansi (char *buf);
int aprintf(char *str,...);
void _fastcall set_screensize (int reservedbotlines,int reservedtoplines);
void _fastcall put_char (char c,char attr,int x,int y);
void _fastcall pos_hardcursor (int x,int y);
void _fastcall hardcursor_off (void);
void _fastcall hardcursor_on (int x,int y);
void _fastcall scroll_up (int tx,int ty,int bx,int by,char attr);
void _fastcall clearwindow (int tx,int ty,int bx,int by,char attr);
void _fastcall cleartoeol (int x,int y,int ex,char attr);
void _fastcall validate_cursor(void);
int _fastcall dputs (int x,int y,char attr,char *s);
int dprintf (int x,int y,char attr,char *str,...);
void _fastcall get_hardcursorpos (int *x,int *y);
extern int fakemaxx,fakemaxy;
extern char curattr;
extern int maxx,maxy;
#ifndef OS2
extern int usebios;
#endif
extern int useansi;
extern int tabspaces;
extern void _fastcall (*pause_mtask)(void);
extern void pascal set_mtask (void);
char quoting = 0;
char chatting = 0;
long timelimit = 1800L;
word baud = 0;
char pauser = 0;
char graphics = 0;
char numlines = 24;
word lines = 0;
long startt = 0;
char commport = 0;
char chatted = 0;
char fname[133] = "";
char mode = 1;
char username[37] = "";
struct ffblk filestat;
char uwidth = 80;
char noslice = 0;
struct line {
char text[81];
char terminator[3];
word num;
struct line *next;
struct line *prior;
};
struct line * start;
struct line * last;
char temporary[257]="";
union REGS rg;
char ansii[8]={30,34,32,36,31,35,33,37};
char from[36]="";
char to[36]="";
char date[20]="";
char subj[72]="";
char thisto[36]="";
word maxlines=(word)65535;
void cdecl main (argc,argv)
int argc;
char *argv[];
{
char s[81];
char temp[127];
char choice;
word linenum=1;
word x;
FILE *fp;
struct line *info;
char *p;
set_screensize(1,0);
ctrlbrk(break_handler);
strset(temporary,0);
aprintf("\n\x1b[0;1;37mXBBS Line Text Editor (LineEd) copyright (c) 1988/89/90/92 by M. Kimes\n"
"Compiled: %s %s\x1b[0m\n",__DATE__,__TIME__);
start=NULL;
last=NULL;
if(argc<2) {
aprintf("\nMust pass filename as first argument\nLineEd -H for help\n");
exit(3);
}
strcpy(fname,argv[1]);
strupr(fname);
do_args(argc,argv);
timelimit += time(NULL);
if(!noslice) set_mtask();
if ((uwidth<32) || (uwidth>80)) uwidth=80;
fossil(INIT,0);
atexit(deinitialize);
if ((fp=fopen("ONLINE.XBS","rb"))!=NULL) {
fgets(username,36,fp);
fclose(fp);
}
else {
if ((fp=fopen("USERINFO.XBS","r"))!=NULL) {
fgets(username,36,fp);
fclose(fp);
username[35]=0;
stripcr(username);
}
}
username[35]=0;
if (!*username) strcpy(username,"Unknown User");
getxbbstime();
cls();
status(1);
status(2);
printg("\x1b[0;1;37m");
printfm("XBBS Text Editor (LineEd) v%s\nWords will wrap at end of lines\n[Enter] on a blank line for options\n",VERSION);
printg("\x1b[0;1;32m");
if (strnicmp(fname,"MSGTMP",6)) {
if (checkafile(fname)) {
printfm("\n%s is a new file.\n",fname);
}
else load(0);
}
else {
strcpy(temp,fname);
if(temp[strlen(temp)-1]!='.') strcat(temp,".");
strcat(temp,"HDR");
if ((fp=fopen(temp,"rt"))!=NULL) {
while(!feof(fp)) {
fgets(temp,127,fp);
temp[127]=0;
stripcr(temp);
p=strtok(temp," ");
p=strtok(0,"\n");
if(!p) continue;
lstrip(p);
rstrip(p);
if(!stricmp(temp,"USER")) {
strncpy(username,p,36);
username[35]=0;
status(1);
status(2);
}
else if(!stricmp(temp,"RECP")) {
strncpy(thisto,p,36);
thisto[35]=0;
}
else if(!stricmp(temp,"FROM")) {
strncpy(from,p,36);
from[35]=0;
}
else if(!stricmp(temp,"TO")) {
strncpy(to,p,36);
to[35]=0;
}
else if(!stricmp(temp,"SUBJ")) {
strncpy(subj,p,72);
subj[71]=0;
}
else if(!stricmp(temp,"DATE")) {
strncpy(date,p,20);
date[19]=0;
}
}
fclose(fp);
if(!*thisto) strcpy(thisto,from);
}
if (!checkafile(fname)) printm("\nQuotes in buffer\n");
else printm("\nNo Quotes available\n");
}
enter (findlast()+1);
remove("0"); /* ???? */
do {
choice=menu_select();
printm("\n");
switch (choice) {
case 0: break;
case 'E':
case 'T': linenum=findlast();
if (!linenum) break;
if (choice=='T') printm("\nReType");
else printm("\nEdit");
printfm(" which line # (1-%u): ",linenum);
strcpy(s,genin(5,0,0,0,NUM));
if (!*s) linenum=findlast();
else linenum=atoi(s);
if (!linenum) {
printm("\nAborted");
break;
}
if (find(linenum)==NULL) {
printfm("\nCan't find line #%u\n",linenum);
break;
}
info=find(linenum);
printg("\x1b[0;1;32m");
printfm("\nLine #%u now reads:\n%03u: %s",linenum,linenum,info->text);
if (choice=='E') {
edit(linenum);
break;
}
strcpy(temporary,info->text);
deleteline(linenum);
printm("\nReType line:");
enter(linenum);
break;
case 'C': info=find(findlast());
if (info && findlast()) {
printg("\x1b[0;2;32m");
printfm("\n%03u: %s",findlast(),info->text);
}
enter(findlast()+1);
break;
case 'I': linenum=findlast();
if (!linenum) break;
if(linenum>=maxlines) {
if(linenum>=maxlines) {
printg("\x1b[0;1;31m");
printm("\nMaximum lines allowed already entered.\n");
break;
}
}
printfm("Begin insertion at line # (1-%u): ",linenum);
linenum=atoi(genin(5,0,0,0,NUM));
if (!linenum) {
printm("\nAborted");
break;
}
if (linenum!=1) if (find (linenum)==NULL) {
printm("\nAborted");
break;
}
if (find(linenum-1)!=NULL) {
info=find(linenum-1);
printg("\x1b[0;1;32m");
printfm("\nPrevious line reads:\n%03u: %s",linenum-1,info->text);
}
enter(linenum);
break;
case 'D': delete();
break;
case 'R': list();
break;
case 'P':
case 'S': if (!findlast()) break;
if (mode) exit(save(1,findlast()));
printm("Enter filename: ");
strcpy(temp,fname);
if (*fname) {
printfm("[%s] ",fname);
}
strcpy(s,genin(79,0,0,0,FLEPW));
if (*s) strcpy(fname,s);
if (!*fname) break;
strupr(fname);
status(1);
status(2);
if (choice=='P') {
printm("\nWARNING: Same as current filename.\n");
linenum=findlast();
printg("\x1b[0;1;37m");
printfm("Save line (1-%u) #",linenum);
strcpy(s,genin(5,0,0,0,NUM));
if (!*s) {
printm("\nAborted\n");
strcpy(fname,temp);
status(1);
status(2);
break;
}
else {
linenum=atoi(s);
if ((linenum<1) || (linenum>findlast())) {
printm("\nAborted");
strcpy(fname,temp);
status(1);
status(2);
break;
}
printm("-#");
strcpy(s,genin(5,0,0,0,NUM));
if (!*s) {
x=linenum;
printfm("%u",x);
}
else {
x=atoi(s);
if ((x<linenum) || (x>findlast())) {
printm("\nAborted");
strcpy(fname,temp);
status(1);
status(2);
break;
}
}
}
save(linenum,x);
strcpy(fname,temp);
status(1);
status(2);
break;
}
save(1,findlast());
break;
case '>':
quoter();
break;
case 'L':
case 'A':
if (!findlast() && choice=='A') break;
if (!mode) {
printm("Enter filename: ");
strcpy(s,genin(79,0,0,0,FLEPW));
if (!*s) break;
strcpy(fname,s);
strupr(fname);
}
if (choice=='L')load(0);
else load(1);
break;
case 'Q': quit(0);
break;
case 'N': if (!findlast()) break;
printm("Erase & start over...are you sure? (Y-n) ");
if (*genin(1,0,1,1,YESNO)=='N') break;
newbuffer();
start=NULL;
last=NULL;
enter(findlast()+1);
break;
case '$': if (mode) break;
rawdir("",1);
break;
case '!': printg("\x1b[0;1;37m");
printfm("\n%lu bytes free.\n",coreleft());
printfm("Filename: %s\n",fname);
printfm("%ld minutes remaining\n",(timelimit-getxbbstime())/60L);
printfm("%u lines remaining\n",maxlines-findlast());
if(*from) printfm("%sfrom %s\n",ORIGMSG,from);
if(*to) printfm("%sto %s\n",ORIGMSG,to);
if(*date) printfm("%sdate: %s\n",ORIGMSG,date);
if(*subj) {
printfm("Subject:\n %s\n",subj);
printm("New SUBJ:\n -> ");
p=genin(72,0,0,0,SUBJECT);
if(strlen(p)>2) strcpy(subj,p);
printm("\n");
}
if(*thisto) {
printfm("This msg to %s\n",thisto);
printm("New TO: ");
p=genin(36,0,0,0,NAME);
if(*p) strcpy(thisto,p);
printm("\n");
}
break;
case 'H':
case '?': view(1);
break;
case 'V': if (mode) break;
view(0);
break;
case 'M': movelines();
break;
case 'F': formpara();
break;
}
} while (1);
}
int cdecl break_handler (void) {
return 1;
}
pascal menu_select() {
char c=0;
strset(temporary,0);
printg("\x1b[0;1;36m");
printfm("\n%ld minutes left.",(timelimit-getxbbstime())/60L);
printm("\n[C]ontinue [I]nsert [D]elete [R]ead ");
if (uwidth<79) printm("\n");
printm("Re[T]ype [N]ewbuff [S]ave [Q]uit [E]dit\n");
printm("[M]ove [F]orm [H]elp [!]Stats [>]Quote ");
if (!mode) {
if (uwidth<79) printm("\n");
printm("[L]oad [A]ppnd [P]rtSve [$]Dir [V]iew");
}
printm("\n-> ");
NoGo:
strset(temporary,0);
printm(BACKSPACE);
c=*genin(1,0,1,1,ALLL);
if (!strchr(">$!FMVPAETNCIDRSQL?H",c)) goto NoGo;
if (((c=='L') || (c=='$') || (c=='A') || (c=='P') || (c=='V')) && (mode)) goto NoGo;
return (c);
}
void pascal formpara (void)
{
char s[162];
char wrapped[162];
word linenum;
struct line *info,*p;
if (findlast()<2) return;
printg("\x1b[0;1;35m");
printfm("\n(%u-%u) Reformat paragraph from which line #: ",1,findlast()-1);
strcpy(s,genin(5,0,0,0,NUM));
if (!*s) {
printm("\nAborted\n");
return;
}
else {
linenum=(word)atol(s);
if ((linenum<1) || (linenum>=findlast())) {
printm("\nAborted");
return;
}
}
info=find(linenum);
if (!info) return;
p=info->next;
if (!p) return;
while (*p->text!=' ' && *p->text) {
strcpy(s,info->text);
if (strstr(".?!:",&info->text[strlen(info->text)-1])) strcat(s," ");
else strcat(s," ");
strcat(s,p->text);
wrap(s,wrapped);
rstrip(s);
if (!*s) strcpy(s," ");
strcpy(info->text,s);
strcpy(info->terminator," \x8d");
if (*wrapped) strcpy(p->text,wrapped);
else {
deleteline(p->num);
p=info;
}
info=p;
p=info->next;
if (!p) break;
}
if (info) strcpy(info->terminator,"\r");
}
word pascal enter (word linenum) {
struct line *info;
char wrapped[81];
if(linenum<=maxlines) {
/* strset(temporary,0); */
strset(wrapped,0);
printheader();
}
do {
if(linenum>maxlines) {
printg("\x1b[0;1;31m");
printm("\nMaximum lines allowed already entered.\n");
return ((word)NULL);
}
info=(struct line *) malloc(sizeof(struct line));
if(!info) {
printm("\nOut of memory\n");
return ((word)NULL);
}
printg("\x1b[0;2;32m");
printfm("\n%03u: ",linenum);
printg("\x1b[0;1;32m");
if (*wrapped) strcpy(temporary,wrapped);
strset(wrapped,0);
strcpy(info->text,genin((uwidth-7),0,0,1,ALLL));
if (!*info->text) break;
info->num=linenum;
status(2);
if (strlen(info->text)<(uwidth-8) || strstr(".?!:",&info->text[strlen(info->text)-1])) strcpy(info->terminator,"\r");
else {
strcpy(info->terminator," \x8d");
if (info->text[(strlen(info->text)-1)]!=' ') {
wrap(info->text,wrapped);
}
}
rstrip(info->text);
if (find(linenum)) {
patchup(linenum,1);
printg("\x1b[0;1;31m");
printm("\n(Inserting)");
}
start=dls_store(info);
linenum++;
} while (1);
return linenum;
}
void pascal wrap (temp,wrapped)
char *temp;
char *wrapped;
{
word register x;
strset(wrapped,0);
rstrip(temp);
if (!*temp) strcpy(temp," ");
if (strlen(temp)<(uwidth-8)) return;
if (!strchr(temp,' ')) return;
if (strlen(temp)>(uwidth-8)) {
strcpy(wrapped,&temp[uwidth-7]);
strrev(wrapped);
temp[uwidth-7]=0;
}
for (x=(word)(uwidth-8);x>0;x--) {
if (temp[x]!=' ') {
printm(BACKSPACE);
strcat(wrapped,&temp[x]);
temp[x]=0;
}
else break;
}
rstrip(temp);
if (!*temp) strcpy(temp," ");
strrev(wrapped);
}
void pascal patchup (n,incr)
word n;
int incr;
{
struct line *i;
i=find(n);
while(i) {
i->num=i->num+incr;
i=i->next;
}
}
struct line * pascal dls_store(i)
struct line *i;
{
struct line *old,*p;
if (last==NULL) {
i->next=NULL;
i->prior=NULL;
last=i;
return i;
}
p=start;
old=NULL;
while(p) {
if (p->num < i->num) {
old=p;
p=p->next;
}
else {
if(p->prior) {
p->prior->next=i;
i->next=p;
i->prior=p->prior;
p->prior=i;
return start;
}
i->next = p;
i->prior=NULL;
p->prior=i;
return i;
}
}
old->next=i;
i->next=NULL;
i->prior=old;
last=i;
return start;
}
char pascal readtext (s)
char *s;
{
struct ffblk filestat;
char dostring[81];
signed char page;
char a;
ulong pos[102];
FILE *fp;
register word x;
if (findfirst(s,&filestat,0)) {
Failed:
printfm("\nCan't read %s\n",s);
return 0;
}
if (!filestat.ff_fsize) {
goto Failed;
}
if((fp=fopen(s,"r"))==NULL) {
goto Failed;
}
page=0;
pos[0]=0;
cls();
printg("\x1b[0;1;33m");
printfm(" -=-=Reading: %s=-=- Page #%hu\n",s,page+1);
printg("\x1b[0;1;32m");
pauser=1;
lines=1;
while ((toupper(inkey())!='S') && (!feof(fp)) && (!ferror(fp))) {
Domore:
if (fgets(dostring,81,fp)==NULL) break;
if (printm(dostring)) break;
if (strlen(dostring)>(uwidth-1)) lines++;
if (lines>=numlines-2) {
if (feof(fp)) break;
pauser=0;
printg("\x1b[0;1;33m");
printm(" [N]ext Page [P]revious Page [O]ver [M]ore [S]top: [N] ");
fossil(FLUSHOUT,0);
fossil(PURGEIN,0);
pos[page+1]=ftell(fp);
Getitagain:
a=*genin(1,0,1,1,ALPHA);
switch (a) {
case 'S': goto Abort;
case 'N':
case 0: a=0;
if (++page>100) page=1;
pos[page]=ftell(fp);
break;
case 'O': fseek(fp,pos[page],SEEK_SET);
break;
case 'P':
case '-': if (page) {
fseek(fp,pos[--page],SEEK_SET);
break;
}
printm(BACKSPACE);
goto Getitagain;
case 'M': for (x=0;x<56;x++) printm(BACKSPACE);
printg("\x1b[0;1;32m");
pauser=1;
lines=numlines-3;
goto Domore;
default: printm(BACKSPACE);
goto Getitagain;
}
cls();
printg("\x1b[0;1;33m");
printfm(" -=-=Reading: %s=-=- Page #%hu\n",s,page+1);
printg("\x1b[0;1;32m");
pauser=1;
lines=1;
}
}
Abort:
pauser=0;
fclose(fp);
if (a=='S') return 1;
hitreturn();
status(1);
status(2);
ansi("\n");
return 0;
}
void pascal view (char type) {
FILE *fp;
char s[81];
char filename[81];
char *p;
if (type==1) {
p=searchpath("LineEd.HLP");
if(p) strcpy(filename,p);
else {
printm("\nSorry, no help available.\n");
return;
}
}
else {
printm("\nFilename to view? ");
strcpy(filename,genin(80,0,1,0,FLEPW));
printm("\n");
}
if (!*filename) return;
printg("\x1b[0;1;33m");
if (checkafile(filename)) {
printfm("\nCan't find %s\n",filename);
return;
}
if (!filestat.ff_fsize) {
printm("\nNull-length file\n");
return;
}
if((fp=fopen(filename,"r"))==NULL) {
printfm("\nCannot open %s\n",filename);
fclose(fp);
return;
}
if (type==1) readtext(filename);
else {
printm("\n[T]yped || [P]aged? [P] ");
if (*genin(1,0,1,1,ALPHA)!='T') readtext(filename);
else {
printm("\n");
pauser = 1;
while ((inkey()!=' ') && (!feof(fp)) && (!ferror(fp))) {
if (fgets(s,80,fp)==NULL) break;
if (printm(s)) break;
}
fclose(fp);
ansi("\n");
pauser=0;
}
}
ansi("\n");
}
void pascal delete () {
char s[80];
word linenum;
word x;
word register y;
linenum=findlast();
if (!linenum) return;
printg("\x1b[0;1;37m");
printfm("Delete line (1-%u) #",linenum);
strcpy(s,genin(5,0,0,0,NUM));
if (!*s) {
linenum=findlast();
x=linenum;
printfm("%u-#%u",linenum,x);
}
else {
linenum=(word)atol(s);
if ((linenum<1) || (linenum>findlast())) {
printm("\nAborted");
return;
}
printm("-#");
strcpy(s,genin(5,0,0,0,NUM));
if (!*s) {
x=linenum;
printfm("%u",x);
}
else {
x=atoi(s);
if ((x<linenum) || (x>findlast())) {
printm("\nAborted");
return;
}
}
}
for(y=linenum;y<=x;y++) {
deleteline(linenum);
}
printm("\n");
}
void pascal deleteline (linenum)
word linenum;
{
struct line *info;
info=find(linenum);
if(info) {
if(start==info) {
start=info->next;
if(start) start->prior=NULL;
else last=NULL;
}
else {
info->prior->next=info->next;
if(info!=last)
info->next->prior=info->prior;
else
last=info->prior;
}
farfree((struct line far*)info);
patchup(linenum+1,-1);
}
}
void pascal edit (word linenum) {
char s[81],temp[81];
struct line *info;
char *p;
word register x;
info=find(linenum);
if (!info) return;
printm("\nString to alter? ");
strcpy(s,genin((uwidth-7),0,0,0,ALLL));
if (!*s) return;
p=strstr(info->text,s);
if (!p) {
printm("\nString not found.\n");
return;
}
printfm("\n%s\n",info->text);
for (x=0;x!=(p-info->text);++x) printm(" ");
for (x=0;x!=strlen(s);++x) printm("^");
printm("\nText to replace string? ");
strcpy(temp,genin((uwidth-7)-(strlen(info->text)-strlen(s)),0,0,0,ALLL));
if (!*temp) {
printm("\nDelete string from line? (y-N) ");
if (*genin(1,0,0,0,YESNO)!='Y') return;
}
x=strlen(s);
strcpy(s,&p[x]);
p[0]=0;
strcat(info->text,temp);
strcat(info->text,s);
printfm("\nLine #%03u now reads:\n%s",linenum,info->text);
return;
}
struct line * pascal find(linenum)
word linenum;
{
struct line *info;
info=start;
while (info) {
if (linenum==info->num) return info;
info=info->next;
}
return NULL;
}
word pascal list()
{
struct line *info;
word register lineno=0;
word register x;
char temp[127];
word lastline;
word prevline;
lastline=findlast();
info=start;
if (lastline>(numlines)) {
printg("\x1b[0;1;37m");
printfm("\nRead from line # (1-%u): ",lastline);
strcpy(temp,genin(5,0,0,0,NUM));
if (!*temp) {
lineno=1;
printm("1");
}
else lineno=atoi(temp);
if ((lineno<1) || (lineno>lastline)) {
lineno=1;
for (x=0;x<strlen(temp);x++) printm(BACKSPACE);
printm("1");
}
printm("\n[Space] to halt\n");
info=find(lineno);
lineno--;
}
prevline=lineno;
while(info) {
lineno++;
pauser=2;
printg("\x1b[0;2;32m");
printfm("%03u: ",info->num);
printg("\x1b[0;1;32m");
printm(info->text);
if (strlen(info->text)>(uwidth-6)) lines++;
pauser=1;
if (printm("\n")) break;
if (info->num==prevline) info->num=info->num+1;
prevline=info->num;
info=info->next;
if (inkey()==' ') break;
}
pauser=0;
return lineno;
}
word pascal findlast()
{
struct line *info;
word lineno=0;
info=start;
while(info) {
lineno++;
info->num=lineno;
info=info->next;
}
return lineno;
}
word pascal save (word first,word tail) {
struct line *info;
char *p;
FILE *fp;
if (!*fname) return 0;
if (!start) {
printm("\nNo text to save.\n");
return(1);
}
if ((fp=fopen(fname,"wb"))==NULL) {
printfm("\nCannot open file %s\n",fname);
return(1);
}
printm("\nSaving ");
if (!mode) printm(fname);
printm("...\n");
info=find(first);
while((info) && (info->num <= tail)) {
p=info->text;
while(*p) putc(*p++,fp);
if (strnicmp(fname,"MSGTMP",6)) {
putc('\r',fp);
putc('\n',fp);
}
else fputs(info->terminator,fp);
info=info->next;
}
fclose(fp);
if(!strnicmp(fname,"MSGTMP",6)) {
char temp[127];
strcpy(temp,fname);
if(temp[strlen(temp)-1]!='.') strcat(temp,".");
strcat(temp,"HDR");
remove(temp);
fp=fopen(temp,"wb");
if(!fp) return 0;
if(*from) fprintf(fp,"NEWTO %s\r\n",from);
if(*subj) fprintf(fp,"NEWSUBJ %s\r\n",subj);
fclose(fp);
}
return(0);
}
struct line * pascal newbuffer() {
struct line *temp;
while(start) {
temp=start;
start=start->next;
farfree((struct line far*)temp);
}
return (temp);
}
void pascal load (char type) {
register unsigned int lnct;
word size;
struct line *info,*temp,*hold;
char len;
char *p;
FILE *fp;
if (!*fname) return;
if (checkafile(fname)) {
printfm("\nCan't find %s.\n",fname);
return;
}
if (!filestat.ff_fsize) {
printm("\nNull-length file.\n");
return;
}
if((fp=fopen(fname,"rb"))==NULL) {
printfm("\nCannot open %s.\n",fname);
return;
}
printg("\x1b[0;1;35m");
lnct=1;
if ((!type) || (!findlast())) {
newbuffer();
temp=NULL;
type=0;
}
else {
temp=start;
while(temp->next) temp=temp->next;
lnct=findlast()+1;
}
if (!type) printm("\nLoading");
else printm("\nAppending");
if (!quoting) {
printfm(" %s...\n",fname);
}
else {
printm(" Quotes...[Space] to halt\n");
}
hold=start;
size=sizeof(struct line);
start=(struct line *)malloc(size);
if(!start) {
printm("\nOut of memory\n");
fclose(fp);
return;
}
else if (type) {
temp->next=start;
start->prior=temp;
}
info=start;
p=info->text;
*p=0;
len=0;
if (quoting) pauser=1;
SkipNewLine:
while (((*p=getc(fp))!=26) && (!feof(fp)) && (!ferror(fp))) {
if (*p=='\n') continue;
if (*p=='\r') goto BlankLine;
p++;
len++;
while(((*p=getc(fp))!='\r') && (len<79) && (!feof(fp)) && (!ferror(fp))) {
if (*p==26) {
*p=0;
break;
}
if ((*p==141) && (!strncmp(fname,"MSGTMP",6))) break;
p++;
len++;
}
BlankLine:
p[1]=0;
len=0;
if (*p==141) {
if (((strlen(info->text)>1) && (p[-1]!=' ')) || (strlen(info->text)==1)) strcpy(info->terminator," \x8d");
else strcpy(info->terminator,"\x8d");
}
else strcpy(info->terminator,"\r");
if ((*p=='\r') || (*p==141)) *p=0;
else p[1]=0;
if (quoting) {
strcpy(info->terminator,"\r");
if((strlen(info->text)+4)>(uwidth-1))lines++;
if(printfm("%03u: %s\n",lnct,info->text))break;
}
if (*p) rstrip(info->text);
info->num=lnct++;
info->next=(struct line *) malloc(size);
if(!info->next) {
printm("\nOut of memory\n");
fclose(fp);
pauser=0;
return;
}
info->prior=temp;
temp=info;
info=info->next;
if (quoting) {
if (inkey()==' ') break;
}
p=info->text;
}
temp->next=NULL;
last=temp;
farfree((struct line far*)info);
if (!type) start->prior=NULL;
else start=hold;
fclose(fp);
pauser=0;
}
char pascal inkey (void) { /* MIMICS BASIC'S INKEY$ FUNCTION */
char arg=0;
rg.h.ah=11;
int86(33,&rg,&rg);
if (rg.h.al) {
rg.h.ah=8;
int86(33,&rg,&rg);
if (rg.h.al)return((char)(rg.h.al));
rg.h.ah=8;
int86(33,&rg,&rg);
arg=specialkey(rg.h.al);
if (arg) return (arg);
}
if (baud) {
arg=carrchk();
if (!(arg & 1)) return (0);
arg=(fossil(RECVWAIT,0));
if (arg==27) return specialmod();
else return (arg);
}
(*pause_mtask)();
return (0);
}
char pascal specialkey (char a) {
char tempause;
char middle[82];
int drive;
char dir[MAXDIR];
tempause=pauser;
pauser=0;
switch (a) {
case 35: /* HANG UP */
fossil(DTR,DOWN);
exit(3);
break;
case 36: /* SysOp SHELL */
printm("\nThe SysOp has jumped to DOS...please wait...\n");
status(0);
fossil(FLUSHOUT,0);
drive=getdisk();
getcurdir(++drive,dir);
fossil(DEINIT,0);
puts("\nEXIT to return to editor");
spawnlp (P_WAIT,"command.com",NULL);
fossil(INIT,0);
setdisk (--drive);
strcpy(middle,"\\");
strcat(middle,dir);
chdir(middle);
chatted=1;
printm("\nThe SysOp has returned...please continue...\n");
status(1);
status(2);
aprintf("\x1b[%d;1H\n",fakemaxy);
break;
case 72: /* MORE TIME */
timelimit+=60L;
status(2);
break;
case 80: /* LESS TIME */
if (timelimit<=getxbbstime()) timelimit=0L;
else timelimit-=60L;
status(2);
break;
case 46: /* CHAT ON/OFF */
chatting=1-chatting;
if (chatting) chat();
return 13;
case 81: /* FREE MEMORY */
{
word tempbaud;
tempbaud=baud;
baud=tempbaud;
printfm("\n%c%lu bytes free.\n",4,coreleft());
baud=tempbaud;
}
case 75:
return 8;
case 77:
return 24;
case 116:
return 23;
case 115:
return 26;
case 79:
return 25;
case 82:
return 22;
case 83:
return 21;
case 71:
return 20;
case 45:
quit(1);
}
startt=getxbbstime();
pauser=tempause;
return 0;
}
void pascal cls (void) /* MIMICS BASIC'S CLS FUNCTION LOCAL & REMOTE */
{
char *p;
lines = 0;
if (graphics) {
p = "\x1b[0m\x1b[2J";
while(*p) {
if(baud) while(!fossil(TRANSMIT,*p)) carrchk();
p++;
}
}
else if(baud) while(!fossil(TRANSMIT,'\x0c')) carrchk();
ansi("\x1b[0m\x1b[2J");
lines = 0;
}
char pascal fossil (function,arg) /* HANDLES MOST USEFUL FOSSIL CALLS */
char function;
char arg;
{
if(!baud) return 0;
if (function == FLUSHOUT) {
do {
carrchk();
rg.h.ah=3;
rg.x.dx=commport;
int86(20,&rg,&rg);
if(!(rg.h.ah & 64)) (*pause_mtask)();
}
while (!(rg.h.ah & 64));
return(0);
}
if (function == WATCHDOG) rg.h.al = arg;
if (function == DTR) rg.h.al = arg;
if (function == TRANSWAIT) rg.h.al = arg;
if (function == TRANSMIT) rg.h.al = arg;
if (function == ONOFF) rg.h.al = arg;
rg.x.dx=commport;
rg.h.ah=function;
int86(20,&rg,&rg);
if (function == INIT) {
if (rg.x.ax != INITOK) {
aprintf("\nFossil not responding...RTFM.");
exit (3);
}
return (0);
}
if (function == GETSTAT) {
arg = rg.h.ah;
if (rg.h.al & 128) {
arg |= 128;
return (arg);
}
arg &= 127;
return (arg);
}
if (function == RECVWAIT) return (rg.h.al);
if (function == TRANSMIT) return (rg.x.ax);
return (0);
}
char pascal printm (char *text) { /* PRINTS TO MODEM AND SCREEN */
char *mmore;
char *p=NULL;
char *pp;
getxbbstime();
p = text;
if (!p || !*p) return (0);
if (strchr(p,'\xc') || strstr(p,"\x1b[2J")) lines=0;
if (baud) {
pp = p;
while (*pp) {
if (*pp == '\n' || (*pp == '\r' && pp[1] != '\n')) {
while (!fossil(TRANSMIT,'\r')) carrchk();
*pp = '\n';
}
while (!fossil(TRANSMIT,*pp++)) carrchk();
}
}
pp = p;
while ((pp = strchr(pp,'\07')) != NULL) memmove(pp,&pp[1],strlen(pp));
ansi(p);
if (baud<4800 && text[1]) fossil(FLUSHOUT,0);
if (!pauser) {
lines=0;
return (0);
}
if (pauser == 2) return(0);
if (++lines >= (numlines - 1)) {
pauser = 0;
printm ("More? (Y-n) ");
fossil(FLUSHOUT,0);
fossil(PURGEIN,0);
mmore = genin(1,0,1,1,YESNOM);
printm ("\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b");
if (*mmore == 'N') {
printm ("\n");
return (1);
}
pauser = 1;
}
return (0);
}
void cdecl deinitialize (void) { /* DEINITIALIZES FOSSIL ON EXIT */
fossil(FLUSHOUT,0);
fossil (DEINIT,0);
fcloseall();
ansi("\x1b[0m\x1b[2JLineEd down...\n");
}
char * pascal genin (length,password,caps,hot,type) /* GENERIC INPUT ROUTINE */
char length;
char password;
char caps;
char hot;
char type;
{
static char input[257];
int x=0;
char one=0;
char temp;
char randchr[2];
pauser=0;
if (*temporary) {
temporary[length]=0;
strcpy(input,temporary);
printm(input);
x=strlen(input);
}
else {
length--;
strset(input,0);
}
startt=getxbbstime();
AfterChat:
while ((getxbbstime()-startt)<241) {
one=inkey();
if (one == '\r') break;
if (one=='\t') {
one=0;
for(;x<=length;++x) {
if (++one>4) break;
printm(" ");
input[x]=' ';
temporary[x]=' ';
input[x+1]=0;
}
goto AfterCtrl;
}
if (one==25) {
if (strlen(temporary)<=strlen(input)) continue;
one=strlen(input);
printm(&temporary[one]);
strcat(input,&temporary[one]);
x=strlen(input);
goto AfterCtrl;
}
if (one==24) {
if (strlen(temporary)<=strlen(input)) continue;
one=strlen(input);
input[x]=temporary[one];
printm(&input[x++]);
goto AfterCtrl;
}
if (one==26) {
if (strlen(temporary)<strlen(input)) continue;
while (input[x]==' ' && *input) {
input[x--]=0;
if (input[x]==' ' && *input) printm(BACKSPACE);
}
while (input[x]!=' ' && *input) {
input[x--]=0;
if (input[x]!=' ' && *input) printm(BACKSPACE);
}
while ((input[x]==' ') && (strlen(input)>0)) {
input[x--]=0;
if (*input) printm(BACKSPACE);
}
x=strlen(input);
goto AfterCtrl;
}
if (one==23) {
if (!strrchr(&temporary[strlen(input)],' ')) continue;
one=strlen(input);
while (temporary[one]==' ') {
input[x++]=temporary[one];
if (temporary[one++]==' ') printm(" ");
}
while ((temporary[one]!=' ') && (temporary[one])) {
input[x++]=temporary[one];
if (temporary[one++]!=' ') printm(&input[x-1]);
}
x=strlen(input);
goto AfterCtrl;
}
if (one==22) {
if (strlen(temporary)<strlen(input)) continue;
one=strlen(input);
temp=strlen(&temporary[one]);
memmove(&temporary[one+1],&temporary[one],temp+1);
temporary[one]=' ';
temporary[length]=0;
goto AfterCtrl;
}
if (one==21) {
if(!strlen(input) || strlen(temporary)<strlen(input)) continue;
one=strlen(input);
temp=strlen(&temporary[one]);
memmove(&temporary[one-1],&temporary[one],temp+1);
goto AfterCtrl;
}
if (one==20) {
while (*input) {
printm(BACKSPACE);
input[strlen(input)-1]=0;
}
x=strlen(input);
goto AfterCtrl;
}
Nogo:
if ((one == 8) || (one == 127)) {
if (x>0) {
printm(BACKSPACE);
input [--x]=0;
if ((type==PHONE) && ((x==2) || (x==5))) printm(BACKSPACE);
if ((type==DATE) && ((x==1) || (x==3))) printm(BACKSPACE);
}
continue;
}
if ((caps) || (type==YESNO) || (type==YESNOM) || (type==FLE) || (type==FLEW) || (type==FLEPW) || (type==FLEP)) one=toupper(one);
if (x <= length)
{
if (type==NAME)
{
if((isalpha(one)==0) && (one!=' ') && (one!='.') && (one!='-') || (x==0 && one==' ')) continue;
if ((one==' ') && (strchr(input,' ')!=NULL)) continue;
}
if (type==NEAT)
{
if((isalnum(one)==0) && (one!=' ') || (x==0 && one==' ')) continue;
}
if ((type==NEAT) || (type==NAME))
{
if(x==0) one=toupper(one);
else one=tolower(one);
}
if((type==NEAT) || (type==NAME))
{
if((x>0) && ((input[x-1]==' ') || (input[x-1]=='.') || (input[x-1]=='-'))) one=toupper(one);
}
if ((type==SUBJECT) && (x==0)) one=toupper(one);
if ((type==SUBJECT) && (isprint(one)==0)) continue;
if ((type==ALLL) && (isprint(one)==0) && (mode==1)) continue;
if ((type==ALLL) && (one==127)) one=8;
if ((type==ALPHA) && (isalpha(one)==0) && (one!=' ')) continue;
if (((type==NUM) || (type==PHONE) || (type==DATE)) && (isdigit(one)==0)) continue;
if ((type==ALPHANUM) && (isalnum(one)==0) && (one!=' ')) continue;
if (((type==YESNO) || (type==YESNOM)) && (one!='Y' && one!='N')) continue;
if (type==FLE)
{
if ((isalnum(one)==0) && (!strchr("._-+=!@#$%^&<>/",one))) continue;
}
if (type==FLEP)
{
if ((isalnum(one)==0) && (!strchr("._-+=!@#$%^&<>/\\:",one))) continue;
}
if (type==FLEW)
{
if ((isalnum(one)==0) && (!strchr("._-+=!@#$%^&<>/?*",one))) continue;
}
if (type==FLEPW)
{
if ((isalnum(one)==0) && (!strchr("._-+=!@#$%^&<>/?*\\:",one))) continue;
}
if ((type==FLE) || (type==FLEP) || (type==FLEW) || (type==FLEPW))
{
if ((one=='.') && (strchr(input,'.')!=NULL)) continue;
}
}
if ((one==1) && (strncmp(fname,"MSGTMP",6)==0)) continue;
if (strchr("\x3\x11\x13\x0b",one)) continue;
if (one && x <= length) {
input[x]=one;
temporary[x]=one;
input[++x]=0;
if (type==YESNOM) {
strset(temporary,0);
return(input);
}
if (!password) printm(&input[x-1]);
else {
randchr[0]=random(10)+33;
randchr[1]=0;
printm(randchr);
}
if ((type==PHONE) && ((x==3) || (x==6))) printm("-");
if ((type==DATE) && ((x==2) || (x==4))) printm("/");
AfterCtrl:
if ((hot)&&(x >= length)) {
strset(temporary,0);
return (input);
}
startt=getxbbstime();
}
}
if (((getxbbstime()-startt)>240) && (!chatted))
{
aprintf("\nUser time-out...\n");
exit (2);
}
if (chatted) {
chatted=0;
strset(input,0);
strset(temporary,0);
return (input);
}
strset(temporary,0);
return (input);
}
char pascal carrchk (void) { /* Checks for carrier */
rg.x.dx=commport;
rg.h.ah=GETSTAT;
int86(20,&rg,&rg);
if(baud) {
if (!(rg.h.al & 128)) {
rg.x.dx=commport;
rg.h.ah=GETSTAT;
int86(20,&rg,&rg);
if (!(rg.h.al & 128)) {
fossil(DTR,DOWN);
ansi("\n\x1b[KLost carrier...");
if (!strncmp(fname,"MSGTMP",6)) {
remove(fname);
if(fname[strlen(fname)-1]!='.') strcat(fname,".");
strcat(fname,"HDR");
remove(fname);
}
exit (2);
}
}
}
return (rg.h.ah);
}
void pascal chat (void) {
char a[81];
char wrapped[81];
int register x;
char tempflag;
strset(temporary,0);
if (chatted) return;
printm("\n\nChat mode engaged\n\n");
while (chatting) {
strcpy(a,genin((uwidth-1),0,0,1,ALLL));
strcat(temporary,a);
strcpy(a,temporary);
strset(temporary,0);
if (!chatting) break;
if (strlen(a)>=(uwidth-2)) {
if (a[strlen(a)-1]!=' ' && strchr(a,' ')) {
strset(wrapped,0);
x=strlen(a)-1;
for (;strlen(a)>0;x--) {
if (a[x]!=' ') {
printm(BACKSPACE);
strcat(wrapped,&a[x]);
a[x]=0;
}
else break;
}
strcpy(temporary,strrev(wrapped));
printm("\n");
}
else printm("\n");
}
else printm("\n\n");
}
printm("\nChat mode ended\n");
chatted++;
strset(temporary,0);
status(1);
status(2);
}
long pascal getxbbstime (void) {
char tempause;
static long xbbs_time;
static long last_time=0L;
static int warned;
tempause=pauser;
pauser=2;
xbbs_time=time(NULL);
if (timelimit<(xbbs_time+120L) && !warned) {
int x;
warned++;
x=wherex();
printfm("\nWARNING: %u minutes remaining for this call.\n",(timelimit-xbbs_time)/60L);
status(1);
status(2);
while(--x) printm(" ");
}
if (timelimit > ((xbbs_time+1L)+120L) && warned) warned=0;
if (timelimit < (xbbs_time+1L)) {
timelimit=xbbs_time+240L;
printm ("\nSorry, time to logoff...\n");
fossil (FLUSHOUT,0);
exit(0);
}
if((xbbs_time-last_time)>60L) {
last_time=xbbs_time;
status(1);
status(2);
}
pauser=tempause;
return(xbbs_time);
}
void pascal rawdir (char *directory,char type) {
int register x=0;
char b;
char *noe;
char noext[10];
char a[124];
char mask[81];
struct ffblk f;
struct fdate
{
bit day: 5;
bit month: 4;
bit year: 7;
};
union df
{
struct fdate fd;
int x;
} fdf;
ulong total=0;
if ((type) && (type!=1)) {
sprintf(a,"%s",directory);
goto Skipask;
}
printm("\nMask? [*.*]: ");
if (!type) strcpy(mask,genin(12,0,1,0,FLEW));
else strcpy(mask,genin(80,0,1,0,FLEPW));
if (!*mask)
{
strcpy(mask,"*.*");
printm("*.*");
}
printm("\n");
sprintf(a,"%s%s",directory,mask);
Skipask:
if (findfirst(a,&f,0))
{
printm("\nNo matching files found.\n");
return;
}
printm("\n[Space] to halt\n");
pauser=1;
do
{
x++;
if ((!type) || (type==1))
{
if (!(x%2)) b='\n';
else b=' ';
}
else
{
if (!(x%3)) b='\n';
else b=' ';
}
strcpy(noext,f.ff_name);
noe=strchr(noext,'.');
if (noe) noe[0]=0;
total=total+f.ff_fsize;
fdf.x=f.ff_fdate;
if (graphics)
{
if (type==2) sprintf(mask,"\x1b[0;1;33m%-9s \x1b[34m%02u/%02u/%u %c",noext,fdf.fd.month,fdf.fd.day,(fdf.fd.year+80)%100,b);
else sprintf(mask,"\x1b[0;1;33m%-13s \x1b[36m%6lu \x1b[34m%02u/%02u/%u %c",f.ff_name,f.ff_fsize,fdf.fd.month,fdf.fd.day,(fdf.fd.year+80)%100,b);
}
else
{
if (type==2) sprintf(mask,"%-9s %02u/%02u/%u %c",noext,fdf.fd.month,fdf.fd.day,(fdf.fd.year+80)%100,b);
else sprintf(mask,"%-13s %6lu %02u/%02u/%u %c",f.ff_name,f.ff_fsize,fdf.fd.month,fdf.fd.day,(fdf.fd.year+80)%100,b);
}
if (b==' ') lines--;
if(printm(mask)) break;
b=toupper(inkey());
if (b==' ') break;
}
while(!findnext(&f));
donereading:
pauser=0;
noext[0]=0;
if (graphics) strcpy(noext,"\x1b[0;1;32m");
printfm("\n%s%u matching files found totalling %lu bytes.",noext,x,total);
if (graphics) printm("\x1b[0;1;31m");
hitreturn();
status(1);
status(2);
ansi("\n");
}
void pascal hitreturn (void) {
startt=getxbbstime();
lines=0;
printm("\n[Enter] to continue...");
while ((getxbbstime()-startt)<241L) {
if ((inkey()==13) || (chatted)) goto hedid;
}
aprintf("\n\x1b[KUser time-out...");
exit (2);
hedid:
chatted=0;
printm("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b \n");
lines=0;
}
char * pascal rstrip (char *a) {
int register x;
x=strlen(a);
while (x && a[x-1]==' ') a[--x]=0;
return a;
}
int pascal checkafile (char *a) {
return (findfirst(a,&filestat,0));
}
void pascal printheader () {
char header[]="\n [----+----1----+----2----+----3----+----4----+----5----+----6----+----7--";
printg("\x1b[0;1;37m");
header[uwidth-1]=0;
printfm("%s]",header);
printg("\x1b[0;1;32m");
}
void pascal quoter () {
if (checkafile(fname)) {
printm("\nNo quotes available\n");
return;
}
quoting=1;
load(1);
quoting=0;
}
void pascal movelines() {
char s[81];
word linenum,x,z;
struct line *blkbeg,*blkend,*leftend,*rightend,*movbeg,*movend,*info;
linenum=findlast();
if (linenum<2) return;
printg("\x1b[0;1;37m");
printfm("Move line (1-%u) #",linenum);
strcpy(s,genin(5,0,0,0,NUM));
if (!*s) {
printm("\nAborted\n");
return;
}
else {
linenum=atoi(s);
if (linenum==findlast()) {
x=linenum;
goto SkipNext;
}
if ((linenum<1) || (linenum>findlast())) {
printm("\nAborted");
return;
}
printm("-#");
strcpy(s,genin(5,0,0,0,NUM));
if (!*s) {
x=linenum;
printfm("%u",x);
}
else {
x=atoi(s);
if ((x<linenum) || (x>findlast())) {
printm("\nAborted");
return;
}
}
SkipNext:
printm(" to which #");
strcpy(s,genin(5,0,0,0,NUM));
z=atoi(s);
if ((z<1) || (z>findlast()) || ((z>=linenum)&&(z<=x))) {
printm("\nAborted");
return;
}
if (z<linenum) {
leftend=find(z-1);
movbeg=find(z);
movend=find(linenum-1);
blkbeg=find(linenum);
blkend=find(x);
rightend=find(x+1);
}
else {
leftend=find(linenum-1);
movbeg=find(linenum);
movend=find(x);
blkbeg=find(x+1);
blkend=find(z);
rightend=find(z+1);
}
if (!leftend) {
blkbeg->prior=NULL;
start=blkbeg;
}
else {
leftend->next=blkbeg;
blkbeg->prior=leftend;
}
if (!rightend) {
movend->next=NULL;
last=movend;
}
else {
rightend->prior=movend;
movend->next=rightend;
}
blkend->next=movbeg;
movbeg->prior=blkend;
x=1;
info=start;
while(info) {
info->num=x++;
info=info->next;
}
}
printm("\nMove complete\n");
}
void pascal status (char type) {
int x,y,oldx,oldy;
get_hardcursorpos(&oldx,&oldy);
if (!type) {
for(x = 0;x < fakemaxx;x++) {
put_char(' ',112,(fakemaxx - 1) - x,maxy - 1);
}
}
else if (type == 1) {
x = dprintf(0,maxy - 1,112," %s @ %u Baud %c %s %c",username,baud,177,fname,177);
if (chatting) x += dprintf(fakemaxx - x,maxy - 1,112," <C>");
for (y = 0;y < fakemaxx - x;y++) put_char(' ',112,(fakemaxx - 1) - y,maxy - 1);
}
else {
dprintf(fakemaxx - 9,maxy - 1,112,"%03ld mins",(timelimit - getxbbstime()) / 60L);
}
pos_hardcursor(oldx,oldy);
}
void pascal quit (char type) {
if (!type) {
printm("Quit (abort)...are you sure? (Y-n) ");
if (*genin(1,0,1,1,YESNO)=='N') {
printm("\n");
return;
}
}
if ((mode) && (!type)) {
if (!strncmp(fname,"MSGTMP",6)) {
remove(fname);
if(fname[strlen(fname)-1]!='.') strcat(fname,".");
strcat(fname,"HDR");
remove(fname);
}
exit(1);
}
else exit(0);
}
int pascal printg (char *text) {
if(graphics) return printm(text);
return 0;
}